package com.project.fortuneteller.mappers;

import com.project.fortuneteller.pojo.Friend;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

import java.util.List;
// 不知道 为什么 @Mapper 注解有的时候会失效
@Mapper
public interface FriendMapper {

    @Select("select * from friend where user_id=#{userId} ")
    List<Friend> selectByUserId(int userId);


    @Select("select friend_id from friend where user_id=#{userId}  ")
    List<Integer> getFriendIdListByUserId(int userId);

    @Select("select count(1) from friend where user_id=#{userId} and friend_id=#{friendId}")
    Integer judgeUserFriendExist(int userId,int friendId);


    @Insert("insert into friend (id,user_id, friend_id, state,create_time) values (#{id},#{userId},#{friendId},#{state}, #{createTime} ) ; ")
    int  insertFriend(Friend friend);
}
